import { app, BrowserWindow } from 'electron';
import { ctl } from './global';

/**
 * 初始化应用事件
 *
 * @author chitanda
 * @date 2022-06-09 15:06:16
 * @export
 */
export function initEvent(): void {
  app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
      app.quit();
    }
  });

  app.on('activate', () => {
    // On macOS it's common to re-create a window in the app when the
    // dock icon is clicked and there are no other windows open.
    if (BrowserWindow.getAllWindows().length === 0) {
      ctl.openMainWindow();
    }
  });
}
